import request from '@/utils/request.js'


const permissionApi = {
    selectPermissionTree() {
        return request.get('/admin/permission/selectPermissionTree', {})
    },
    selectByParentId(id) {
        return request.get(`/admin/permission/selectByParentId/${id}`, {})
    },
    deleteById(id) {
        return request.delete(`/admin/permission/deleteById/${id}`)
    },
    add(permission) {
        return request.post('/admin/permission/add', permission)
    },
    selectById(id) {
        return request.get(`/admin/permission/selectById/${id}`)
    },
    update(permission) {
        return request.put('/admin/permission/update', permission)
    },
    selectAssignedPermission(roleId) {
        return request.get(`/admin/permission/selectAssignedPermission/${roleId}`)
    },
    assignPermission(roleId, permissionIds) {
        return request.post(`/admin/permission/assignPermission`, null, {params: {roleId, permissionIds}})
    }
}

export default permissionApi
